package gui;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 * @file ServiceJobs.java
 * @version 0.1
 * @author James Dibble 10009689
 */
@Entity
@Table(name = "service_jobs", catalog = "dms", schema = "")
@NamedQueries({
    @NamedQuery(name = "ServiceJobs.findAll", query = "SELECT s FROM ServiceJobs s"),
    @NamedQuery(name = "ServiceJobs.findById", query = "SELECT s FROM ServiceJobs s WHERE s.id = :id"),
    @NamedQuery(name = "ServiceJobs.findByCompleted", query = "SELECT s FROM ServiceJobs s WHERE s.completed = :completed"),
    @NamedQuery(name = "ServiceJobs.findByDerlbrcost", query = "SELECT s FROM ServiceJobs s WHERE s.derlbrcost = :derlbrcost"),
    @NamedQuery(name = "ServiceJobs.findByDerpartscost", query = "SELECT s FROM ServiceJobs s WHERE s.derpartscost = :derpartscost")})
public class ServiceJobs implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Lob
    @Column(name = "service_log")
    private String serviceLog;
    @Basic(optional = false)
    @Column(name = "completed")
    @Temporal(TemporalType.TIMESTAMP)
    private Date completed;
    @Basic(optional = false)
    @Column(name = "derlbrcost")
    private long derlbrcost;
    @Basic(optional = false)
    @Column(name = "derpartscost")
    private long derpartscost;
    // <editor-fold defaultstate="collapsed" desc="Attributes">
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructors">
    public ServiceJobs() {
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Methods">
    // </editor-fold>

    public ServiceJobs(Integer id) {
        this.id = id;
    }

    public ServiceJobs(Integer id, String serviceLog, Date completed, long derlbrcost, long derpartscost) {
        this.id = id;
        this.serviceLog = serviceLog;
        this.completed = completed;
        this.derlbrcost = derlbrcost;
        this.derpartscost = derpartscost;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public String getServiceLog() {
        return serviceLog;
    }

    public void setServiceLog(String serviceLog) {
        String oldServiceLog = this.serviceLog;
        this.serviceLog = serviceLog;
        changeSupport.firePropertyChange("serviceLog", oldServiceLog, serviceLog);
    }

    public Date getCompleted() {
        return completed;
    }

    public void setCompleted(Date completed) {
        Date oldCompleted = this.completed;
        this.completed = completed;
        changeSupport.firePropertyChange("completed", oldCompleted, completed);
    }

    public long getDerlbrcost() {
        return derlbrcost;
    }

    public void setDerlbrcost(long derlbrcost) {
        long oldDerlbrcost = this.derlbrcost;
        this.derlbrcost = derlbrcost;
        changeSupport.firePropertyChange("derlbrcost", oldDerlbrcost, derlbrcost);
    }

    public long getDerpartscost() {
        return derpartscost;
    }

    public void setDerpartscost(long derpartscost) {
        long oldDerpartscost = this.derpartscost;
        this.derpartscost = derpartscost;
        changeSupport.firePropertyChange("derpartscost", oldDerpartscost, derpartscost);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ServiceJobs)) {
            return false;
        }
        ServiceJobs other = (ServiceJobs) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gui.ServiceJobs[ id=" + id + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
}
